package base;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Fragment的基类
 * @author Anson-pc
 *
 */
public abstract class BaseFragmentCommen extends Fragment {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		init();
		super.onCreate(savedInstanceState);
	}
	
	/**
	 * 初始化，子类可以选择性复写
	 *
	 */
	protected void init() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return initView();
	}
	
	/**
	 * 初始化视图
	 * 必须实现，这个方法必须是抽象方法
	 */
	protected abstract View initView() ;

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		initData();
		initListener();
		super.onActivityCreated(savedInstanceState);
	}

	/**
	 * 初始化监听器
	 */
	protected void initListener() {
		// TODO Auto-generated method stub
		
	}

	/**
	 * 初始化数据
	 */
	protected void initData() {
		// TODO Auto-generated method stub
		
	}

}
